var external_change_request_by = [['供应商需求' , '供应商需求'] , ['长虹需求' , '长虹需求']];
var external_change_type = [['公司名称' , '公司名称'] , ['原材料' , '原材料'] , ['工艺流程（设备/作业方法）' , '工艺流程（设备/作业方法）'] , ['产地' , '产地'] , ['包装/标识' , '包装/标识'] , ['设计改进' , '设计改进'] , ['管理层' , '管理层'] , ['体系（质量/环境）' , '体系（质量/环境） '] , ['其他' , '其他']];

// 外部变更管理
function getExternalChangeManagePanel(t) {return new CMS.ExternalChangeManagePanel(t)};
var EXTERNAL_CHANGE_MANAGE_PANEL;
CMS.ExternalChangeManagePanel = function(title) {
	EXTERNAL_CHANGE_MANAGE_PANEL = this;
	var objArr = converArr([
		{name:'id' , width:50 , sortable:true , header:'变更号'},
		{name:'supplierName' , width:120 , sortable:true , header:'供应商名称'},
		{name:'supplierCode',hidden:true},
		{name:'materialCode',hidden:true},
		{name:'materialName' , width:120 , sortable:true , header:'物料名称'},
		{name:'materialSerialNumber' , width:120 , sortable:true , header:'物料型号'},
		{name:'appliedDate' , width:120 , sortable:true , header:'变更申请时间'},
		{name:'appliedBy',hidden:true},
		{name:'appliedByName',hidden:true},
		{name:'changeRequestedBy' , width:120 , sortable:true , header:'变更需求单位'},
		{name:'changeType' , width:120 , sortable:true , header:'变更类型'},
		{name:'statusString' , width:120 , sortable:true , header:'状态'},
		{name:'changeReasonContent',hidden:true},
		{name:'beforeChangeStatus',hidden:true},
		{name:'afterChangeStatus',hidden:true},
		{name:'impactForCustomerAfterChange',hidden:true},
		{name:'externalVerifyReportURL',hidden:true},
		{name:'numberOfStorage',hidden:true},
		{name:'storageProcessAdvise',hidden:true},
		{name:'numberOfOnWay',hidden:true},
		{name:'onWayProcessAdvise',hidden:true},
		{name:'internalChangeId',hidden:true},
		{name:'evaDeptId',hidden:true},
		{name:'evaDeptName',hidden:true},
		{name:'evaDeptMgrId',hidden:true},
		{name:'evaDeptMgrName',hidden:true},
		{name:'evaLeaderId',hidden:true},
		{name:'evaLeaderName',hidden:true},
				
		{name:'productName',hidden:true},
		{name:'productSerialNumber',hidden:true},
		{name:'evaImpactForReliability',hidden:true},
		{name:'evaImpactForReliabilityString',hidden:true},
		{name:'evaImpactForProductHandle',hidden:true},
		{name:'evaImpactForProductHandleString',hidden:true},
		{name:'evaImpactForProduceEfficiency',hidden:true},
		{name:'mustVerify',hidden:true},
		{name:'mustVerifyString',hidden:true},
		{name:'mustAlertCustomer',hidden:true},
		{name:'mustAlertCustomerString',hidden:true},
		{name:'mustSpplierChange',hidden:true},
		{name:'mustSpplierChangeString',hidden:true},
		{name:'productTreatmentAdvise',hidden:true},
		{name:'result',hidden:true},
		{name:'resultString',hidden:true},
		{name:'evaComments',hidden:true},
		{name:'evaDate',hidden:true},
		{name:'resultReportUrl',hidden:true},
		
		{name:'sampleReportURL',hidden:true},
		{name:'sampleIsQualified',hidden:true},
		{name:'sampleIsQualifiedString',hidden:true},
		{name:'smallReportURL',hidden:true},
		{name:'smallIsQualified',hidden:true},
		{name:'smallIsQualifiedString',hidden:true},
		{name:'middleReportURL',hidden:true},
		{name:'middleIsQualified',hidden:true},
		{name:'middleIsQualifiedString',hidden:true},
		{name:'isFinishedAlertCustomer',hidden:true},
		{name:'isFinishedAlertCustomerString',hidden:true},
		{name:'alertCustomerNumber',hidden:true},
		{name:'isFinishedSupChange',hidden:true},
		{name:'isFinishedSupChangeString',hidden:true},
		{name:'finishedSupChangeNumber',hidden:true},
		{name:'isFinishedSecurity',hidden:true},
		{name:'isFinishedSecurityString',hidden:true},
		{name:'attachmentForAlert',hidden:true},
		{name:'other',hidden:true},
		{name:'changeResultIsQualify',hidden:true},
		{name:'changeResultIsQualifyString',hidden:true},
		{name:'isApproveChange',hidden:true},
		{name:'isApproveChangeString',hidden:true},
		{name:'rejectReason',hidden:true},
		{name:'verifyMembers',hidden:true},
		{name:'deployChangeDate',hidden:true},
		{name:'resultReportUrl',hidden:true},
		{name:'rejectedByName',hidden:true},
		{name:'rejectedDate',hidden:true},
		{name:'rejectedReason',hidden:true},
		{name:'testPlanApprover',hidden:true},
		{name:'testPlanRejectedReason',hidden:true},
		{name:'testItemsString',hidden:true},
		
		{name:'researchDeptIsBomChanged',hidden:true},
		{name:'researchDeptIsBomChangedString',hidden:true},
		{name:'researchDeptIsDrawingChnaged',hidden:true},
		{name:'researchDeptIsDrawingChnagedString',hidden:true},
		{name:'researchDeptIsDesignDocChanged',hidden:true},
		{name:'researchDeptIsDesignDocChangedString',hidden:true},
		{name:'researchDeptFinishedDate',hidden:true},
		{name:'researchDeptUserId',hidden:true},
		{name:'researchDeptUserName',hidden:true},
		{name:'researchDeptAttachment',hidden:true},
		{name:'engineeringDeptIsBomChanged',hidden:true},
		{name:'engineeringDeptIsBomChangedString',hidden:true},
		{name:'engineeringDeptIsSopChanged',hidden:true},
		{name:'engineeringDeptIsSopChangedString',hidden:true},
		{name:'engineeringDeptIsMoldChanged',hidden:true},
		{name:'engineeringDeptIsMoldChangedString',hidden:true},
		{name:'engineeringDeptIsProcChanged',hidden:true},
		{name:'engineeringDeptIsProcChangedString',hidden:true},
		{name:'engineeringDeptIsQcChanged',hidden:true},
		{name:'engineeringDeptIsQcChangedString',hidden:true},
		{name:'engineeringDeptFinishedDate',hidden:true},
		{name:'engineeringDeptUserId',hidden:true},
		{name:'engineeringDeptUserName',hidden:true},
		{name:'engineeringDeptAttachment',hidden:true},
		{name:'qualityDeptIsInspectDocChanged',hidden:true},
		{name:'qualityDeptIsInspectDocChangedString',hidden:true},
		{name:'qualityDpetIsTrained',hidden:true},
		{name:'qualityDpetIsTrainedString',hidden:true},
		{name:'qualityDpetIsUpgradeInspection',hidden:true},
		{name:'qualityDpetIsUpgradeInspectionString',hidden:true},
		{name:'qualityDeptIsMarkInFirst3',hidden:true},
		{name:'qualityDeptIsMarkInFirst3String',hidden:true},
		{name:'qualityDeptFinishedDate',hidden:true},
		{name:'qualityDeptUserId',hidden:true},
		{name:'qualityDeptUserName',hidden:true},
		{name:'qualityDeptAttachment',hidden:true},
		{name:'productDeptIsMaterialChecked',hidden:true},
		{name:'productDeptIsMaterialCheckedString',hidden:true},
		{name:'productDeptIsTrained',hidden:true},
		{name:'productDeptIsTrainedString',hidden:true},
		{name:'productDeptIsRegisted',hidden:true},
		{name:'productDeptIsRegistedString',hidden:true},
		{name:'productDeptFinishedDate',hidden:true},
		{name:'productDeptUserId',hidden:true},
		{name:'productDeptUserName',hidden:true},
		{name:'productDeptAttachment',hidden:true},
		{name:'summaryIsNumberBeforeChangeSup',hidden:true},
		{name:'summaryIsNumberBeforeChangeSupString',hidden:true},
		{name:'summaryNumberBeforeChangeSup',hidden:true},
		{name:'summaryDeliverDateAfterChange',hidden:true},
		{name:'summaryIsNumberBeforeChangeProd',hidden:true},
		{name:'summaryIsNumberBeforeChangeProdString',hidden:true},
		{name:'summaryNumberBeforeChangeProd',hidden:true},
		{name:'summaryIsImpactShipMent',hidden:true},
		{name:'summaryIsImpactShipMentString',hidden:true},
		{name:'summaryNewProdBatchNumber',hidden:true},
		{name:'summaryNewProdDeliverDate',hidden:true},
		{name:'summaryDeptUserId',hidden:true},
		{name:'summaryDeptUserName',hidden:true},
		{name:'summaryDeptAttachment',hidden:true},
		{name:'status',hidden:true},
		
		{name:'id',header:'操作',width:280, renderer:function(v,c,row) {
			var data = row.data;
			var status = data['status'];
			var ret=' <a href="javascript:EXTERNAL_CHANGE_MANAGE_PANEL.viewDetail()">查看详情</a>'
				+' <a href="javascript:EXTERNAL_CHANGE_MANAGE_PANEL.viewReportDetail()">查看通知单</a>';
				
			if(data['evaDeptMgrId']==login_user_id && status==1)
				ret +=' <a href="javascript:EXTERNAL_CHANGE_MANAGE_PANEL.setVerifyTeam()">组织验证人员</a>';
			if(data['evaLeaderId']==login_user_id && status==2)	
				ret +=' <a href="javascript:EXTERNAL_CHANGE_MANAGE_PANEL.createInternalChangeRequest()">创建内部变更申请</a>';
			return ret;
		}}
	] , true);
	var materialNameSearch = getField({width:190,name:'materialName'});
	var ds = getPageDs(exchg_base_url + 'getExternalChanges' , 'id' , objArr);
	var pageBar = getPageBBar(20 , ds);
	CMS.ExternalChangeManagePanel.superclass.constructor.call(this, {
		title:title,store:ds,view:getGridView('没有找到数据'),
		columns:objArr.columns,sm:getRowModel(),bbar:pageBar,
		id:'external_change_manager_panel',tbar:['-',{
			text:'物料名称：'
		},materialNameSearch ,'-' ,{
			text:'新增',iconCls:'add',handler:function() {
				EXTERNAL_CHANGE_MANAGE_PANEL.editInfo(pub_add_option);
			}
		},'-']
	});
	this.refresh = function() {
       ds.load({params:{start:0,limit:pageBar.pageSize}});
    };
    registPageDsParams(ds , [materialNameSearch] , EXTERNAL_CHANGE_MANAGE_PANEL.refresh);
    EXTERNAL_CHANGE_MANAGE_PANEL.refresh();
    
    //编辑
    this.editInfo = function(type) {
    	var dWidth = 340;
    	
    	var items = [
    		getHidden({name:'id',allowNull:true}),
    		getField({width:dWidth,name:'supplierName',fieldLabel:'供应商名称'}),
    		getField({width:dWidth,name:'supplierCode',fieldLabel:'供应商代码'}),
    		getField({width:dWidth,name:'materialCode',fieldLabel:'物料代码'}),
    		getField({width:dWidth,name:'materialName',fieldLabel:'物料名称'}),
    		getField({width:dWidth,name:'materialSerialNumber',fieldLabel:'物料型号'}),
    		createNormlCommon(dWidth , external_change_request_by , '变更需求单位' , '' , false, 'changeRequestedBy'),
    		createNormlCommon(dWidth , external_change_type , '变更类型' , '' , true, 'changeType'),
    		getArea({width:dWidth + 60,height:60,name:'changeReasonContent',fieldLabel:'变更原因及内容描述',allowNull:true}),
    		getArea({width:dWidth + 60,height:60,name:'beforeChangeStatus',fieldLabel:'变更前状态',allowNull:false}),
    		getArea({width:dWidth + 60,height:60,name:'afterChangeStatus',fieldLabel:'变更后状态',allowNull:false}),
    		getArea({width:dWidth + 60,height:60,name:'impactForCustomerAfterChange',fieldLabel:'变更后可能对客户的影响',allowNull:false}),
    		{xtype:'textfield', fieldLabel:'申请方验证报告', inputType:'file', name:'image', width:dWidth},
    		getField({width:dWidth,name:'numberOfStorage',fieldLabel:'在库品数量',regex:/^\d{0,}$/, regexText: "只能输入数字"}),
    		getField({width:dWidth,name:'storageProcessAdvise',fieldLabel:'处理意见'}),
    		getField({width:dWidth,name:'numberOfOnWay',fieldLabel:'在途品数量',regex:/^\d{0,}$/, regexText: "只能输入数字"}),
    		getField({width:dWidth,name:'onWayProcessAdvise',fieldLabel:'处理意见'})
    	];
    	
    	if(type==pub_edit_option){
    		pubEditRow(type ,items , EXTERNAL_CHANGE_MANAGE_PANEL , '外部变更' , 400 , 600 , chg_base_url + 'saveInternalChange', INTERNAL_CHANGE_MANAGE_PANEL.refresh);
    	}else{
    		var form1 = new Ext.form.FormPanel({
				bodyStyle:'padding:5px',
		    	deferredRender:false,
		    	defaultType: 'textfield',
		    	region:'center',
		    	items:items,
		    	fileUpload:true,
		    	labelWidth:85,
		    	autoScroll:true,
		    	id:'form1'
		    });
    		var win = getEmptyPanel3([{
	    		text:'提交',name:'submit', handler:function() {
	    			var params = checkObjs(items,{id:id});
	    			var formObj = form1.getForm();
	    			if(!formObj.isValid())return;
	    			if(params) {
	    				choseEvaluateDepartment('选择评审部门和领导' , function(evaDept,evaDeptMgr) {		
							params = checkObjs(items,{id:id,evaDeptId:evaDept,evaDeptMgrId:evaDeptMgr,type:type});
							formObj.submit({
								url:exchg_base_url + 'saveExternalChange',
							   	params:params,
							   	waitTitle: '请稍后',
							   	waitMsg:'提交中...',
							   	success:function(form1,resp) {
							   		uploadCallBack(resp);
								},
							    failure:function(form1,resp){
							    	uploadCallBack(resp);
							    }
							});
						});
	    			}
	    		}
	    	}] , '外部变更' , form1 , 500 , 600);
	    	var uploadCallBack = function(resp) {
			 	var obj = resp.result;
			   	showTip2('消息' , obj.msg , 3);
			   	EXTERNAL_CHANGE_MANAGE_PANEL.refresh();
			   	if(obj.status == '1') win.close();
			};
    	}
    };
    
    // 查看申请单详情
    this.viewDetail = function(){
    	var rowObj = EXTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected();
    	var htmlCode = SPRNSTR + '<table class=\"table\" style=\"table-layout:fixed;word-break: break-all;word-wrap:break-word;\" width=\"100%\"><tbody><tr><td class=\"plat_table-row-over\" width=\"30%\">名称</td><td class=\"plat_table-row-over\">内容</td></tr>'
    		+ '<tr><td>变更序号</td><td>'+rowObj.data['id']+'</td></tr>'
    		+ '<tr><td>供应商名称</td><td>'+rowObj.data['supplierName']+'</td></tr>'
    		+ '<tr><td>供应商代码</td><td>'+rowObj.data['supplierCode']+'</td></tr>'
    		+ '<tr><td>物料代码</td><td>'+rowObj.data['materialCode']+'</td></tr>'
    		+ '<tr><td>物料名称</td><td>'+rowObj.data['materialName']+'</td></tr>'
    		+ '<tr><td>物料类型</td><td>'+rowObj.data['materialSerialNumber']+'</td></tr>'
    		+ '<tr><td>变更申请时间</td><td>'+rowObj.data['appliedDate']+'</td></tr>'
    		+ '<tr><td>申请提交人</td><td>'+rowObj.data['appliedByName']+'</td></tr>'
    		+ '<tr><td>变更需求单位</td><td>'+rowObj.data['changeRequestedBy']+'</td></tr>'
    		+ '<tr><td>变更类型</td><td>'+rowObj.data['changeType']+'</td></tr>'
    		+ '<tr><td>变更原因及内容描述</td><td>'+rowObj.data['changeReasonContent']+'</td></tr>'
    		+ '<tr><td>变更前状态</td><td>'+rowObj.data['beforeChangeStatus']+'</td></tr>'
    		+ '<tr><td>变更后状态</td><td>'+rowObj.data['afterChangeStatus']+'</td></tr>'
    		+ '<tr><td>变更后可能存在对客户的影响</td><td>'+rowObj.data['impactForCustomerAfterChange']+'</td></tr>'
    		+ '<tr><td>客户方验证报告</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['externalVerifyReportURL']+'>附件</a></td></tr>'
    		+ '<tr><td>在库品数量</td><td>'+rowObj.data['numberOfStorage']+'</td></tr>'
    		+ '<tr><td>处理意见</td><td>'+rowObj.data['storageProcessAdvise']+'</td></tr>'
    		+ '<tr><td>在途品数量</td><td>'+rowObj.data['numberOfOnWay']+'</td></tr>'
    		+ '<tr><td>处理意见</td><td>'+rowObj.data['onWayProcessAdvise']+'</td></tr>'
    		+ '<tr><td>内部变更序号</td><td>'+rowObj.data['internalChangeId']+'</td></tr>'
    		+ '<tr><td>产品安全、可靠性影响</td><td>'+rowObj.data['evaImpactForReliabilityString']+'</td></tr>'
    		+'<tr><td>在产品、原物料处理风险</td><td>'+rowObj.data['evaImpactForProductHandleString']+'</td></tr>'
    		+'<tr><td>生产效率的影响</td><td>'+rowObj.data['evaImpactForProduceEfficiency']+'</td></tr>'
    		+'<tr><td>是否需要验证</td><td>'+rowObj.data['mustVerifyString']+'</td></tr>'
    		+'<tr><td>是否需要通报客户</td><td>'+rowObj.data['mustAlertCustomerString']+'</td></tr>'
    		+'<tr><td>是否需要供应商变更</td><td>'+rowObj.data['mustSpplierChangeString']+'</td></tr>'
    		+'<tr><td>成品及原物料处理意见</td><td>'+rowObj.data['productTreatmentAdvise']+'</td></tr>'
    		+'<tr><td>评审结论</td><td>'+rowObj.data['resultString']+'</td></tr>'
    		+'<tr><td>评审组长</td><td>'+rowObj.data['evaLeaderName']+'</td></tr>'
    		+'<tr><td>评审部门领导</td><td>'+rowObj.data['evaDeptMgrName']+'</td></tr>'
    		+'<tr><td>评审部门</td><td>'+rowObj.data['evaDeptName']+'</td></tr>'
    		+'<tr><td>评审时间</td><td>'+rowObj.data['evaDate']+'</td></tr>'
    		+'<tr><td>状态</td><td>'+rowObj.data['statusString']+'</td></tr>';
    		
    	htmlCode += '</tbody></table>' + EPRNSTR;
    	var btns = [{
			text:'打印申请单',handler:function() {
				printPage(htmlCode);
			}
		},{
			text:'关闭',handler:function() {
				win.close();
			}
		}];
		
    	var win = new Ext.Window({
			height:500 , width:600 , layout:'border',title:'变更申请单详情',buttonAlign:'center',items:[{
				border:false,closable:true,scripts:true,autoScroll:true,region:'center',
	            discardUrl:true,nocache:true,timeout:9000,scope:this,html:htmlCode
			}],buttons:btns
		});
		win.show();
    }
    // 设置验证人员组
    this.setVerifyTeam = function(){
    	var dWidth = 340;
    	var id = EXTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
    	var evaDeptId = EXTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['evaDeptId'];
    	var items = [
    		createProxyComm2({width:dWidth,emptyText:'请选择...',name:'evaLeaderId',fieldLabel:'评审组长',allowBlank:false},{url:sys_base_url + 'getUsersByDept?deptId='+evaDeptId})
		];
    	var form = getMyEmptyForm(items);
   		var win = getEmptyPanel3([{
    		text:'提交' , handler:function() {
    			var params = checkObjs(items,{id:id});
    			if(!form.getForm().isValid())return;
    			if(params) {
		    		ajax({
			   			url:exchg_base_url + 'setVerifyTeam',
			   			params:params,
		    			waitMsg:'提交中...',
				    	success:function(resp) {
			    			ajaxSuc(resp , EXTERNAL_CHANGE_MANAGE_PANEL.refresh , null , win);
			    		}
			   		});
    			}
    		}
    	}] , '设置评审组长' , form , 100 , 600);
    };
    
    // 创建内部变更申请
    this.createInternalChangeRequest = function(){
    	var dWidth = 340;
    	var id = EXTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected().data['id'];
    	
    	var effectiveV = createNormlCommon(dWidth , effective_type , '变更时效' , '' , false, 'effectiveV');
    	var effectiveStartDate = creDate({fieldLabel:'开始日期',name:'effectiveStartDate',width:dWidth});
    	var effectiveEndDate = creDate({fieldLabel:'结束日期',name:'effectiveEndDate',width:dWidth});
    	var emergencyV = createNormlCommon(dWidth , change_emergency_type , '变更紧急度状态' , '' , false, 'emergencyV');
    	var reasonCodeV = createNormlCommon(dWidth , reason_code_type , '变更理由' , '' , false, 'reasonCodeV');
    	var items = [
    		getHidden({name:'id',allowNull:true}),
    		getHidden({name:'evaDeptId',allowNull:true}),
    		//createProxyComm2({width:dWidth,emptyText:'请选择...',name:'productId',fieldLabel:'适用产品'},{url:sys_basdata_url + 'getProductKV'}),
    		getField({width:dWidth,name:'productName',fieldLabel:'适用产品'}),
    		getField({width:dWidth,name:'productSerialNumber',fieldLabel:'适用型号'}),
    		getField({width:dWidth,name:'project',fieldLabel:'适用工程'}),
    		emergencyV,
    		getHidden({name:'emergency',allowNull:true}),
    		getHidden({name:'effective',allowNull:true}),
    		effectiveV,effectiveStartDate,effectiveEndDate,
    		reasonCodeV,
    		getHidden({name:'reasonCode',allowNull:true}),
    		getField({width:dWidth,name:'supportAccordance',fieldLabel:'支撑依据'}),
    		getArea({width:dWidth + 60,height:60,name:'reasonDesc',fieldLabel:'变更原因简述',allowNull:true}),
    		getArea({width:dWidth + 60,height:60,name:'beforeChangeStatus',fieldLabel:'变更前状态',allowNull:false}),
    		getArea({width:dWidth + 60,height:60,name:'afterChangeStatus',fieldLabel:'变更后状态',allowNull:false}),
    		{xtype:'textfield', fieldLabel:'附件', inputType:'file', name:'image', width:dWidth}
    	];
    	
    	effectiveV.on('select' , function() {
    		if(effectiveV.getValue() == '1'){
				effectiveStartDate.hide();
				effectiveEndDate.hide();
				effectiveStartDate.allowNull = true;
				effectiveEndDate.allowNull = true;
			}else{
				effectiveStartDate.show();
				effectiveEndDate.show();
				effectiveStartDate.allowNull = false;
				effectiveEndDate.allowNull = false;
			}
    	});
    	
    	var form1 = new Ext.form.FormPanel({
			bodyStyle:'padding:5px',
		   	deferredRender:false,
		  	defaultType: 'textfield',
		   	region:'center',
		   	items:items,
		   	fileUpload:true,
		  	labelWidth:85,
		   	autoScroll:true,
		  	id:'form1'
		});
    	var win = getEmptyPanel3([{
	    	text:'提交' , handler:function() {
	    		var formObj = form1.getForm();
	    		if(!formObj.isValid())return;
	    		var params = checkObjs(items,{externalChangeId:id});
	    		if(params) {
		    		choseDepartmentMgr('选择批准科长' , function(approvedMgrId) {		
		    			params = checkObjs(items,{externalChangeId:id,approvedMgrId:approvedMgrId});	
			    		formObj.findField("emergency").setValue(emergencyV.getValue());
			    		formObj.findField("effective").setValue(effectiveV.getValue());
			    		formObj.findField("reasonCode").setValue(reasonCodeV.getValue());
			    		formObj.submit({
				   			url:chg_base_url + 'createInternalChange',
				   			params:params,
				   			waitTitle: '请稍后',
				   			waitMsg:'提交中...',
				   			success:function(form1,resp) {
						    	uploadCallBack(resp);
						    },
						    failure:function(form1,resp){
						    	uploadCallBack(resp);
						    }
				   		});
				   		var uploadCallBack = function(resp) {
					    	var obj = resp.result;
					    	showTip2('消息' , obj.msg , 3);
					    	EXTERNAL_CHANGE_MANAGE_PANEL.refresh();
					    	if(obj.status == '1') win.close();
					    }
		    		} , win);
	    		}
	    	}
	    }] , '内部变更' , form1 , 500 , 600);
    };
    
    this.viewReportDetail = function(){
    	var rowObj = EXTERNAL_CHANGE_MANAGE_PANEL.getSelectionModel().getSelected();
    	var sampleReportURL = rowObj.data['sampleReportURL'];
		var smallReportURL = rowObj.data['smallReportURL'];
		var middleReportURL = rowObj.data['middleReportURL'];
		
		var status = rowObj.data['status'];
				
    	var htmlCode = SPRNSTR + '<table class=\"table\" style=\"table-layout:fixed;word-break: break-all;word-wrap:break-word;\" width=\"100%\"><tbody><tr><td class=\"plat_table-row-over\" width=\"30%\">名称</td><td class=\"plat_table-row-over\">内容</td></tr>';
    	
    	htmlCode += '<tr><td>供应商名称</td><td>'+rowObj.data['supplierName']+'</td></tr>'
    			+'<tr><td>变更依据</td><td>'+rowObj.data['internalChangeId']+'</td></tr>'
    			'<tr><td>物料名称</td><td>'+rowObj.data['materialName']+'</td></tr>'
    			'<tr><td>物料型号</td><td>'+rowObj.data['materialSerialNumber']+'</td></tr>'
    			'<tr><td>供方代码</td><td>'+rowObj.data['supplierCode']+'</td></tr>'
    			'<tr><td>用于长虹产品</td><td>'+rowObj.data['productName']+'</td></tr>'
    			'<tr><td>适用型号</td><td>'+rowObj.data['productSerialNumber']+'</td></tr>';
    	if(	sampleReportURL != ""){
			htmlCode += '<tr><td>样品验证报告</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['sampleReportURL']+'>样本测试报告</a></td></tr>'
    			+ '<tr><td>样品是否合格</td><td>'+rowObj.data['sampleIsQualifiedString']+'</td></tr>';
		}
    	if( smallReportURL != ""){
			htmlCode += '<tr><td>小批量验证报告</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['smallReportURL']+'>小批量测试报告</a></td></tr>'
    			+ '<tr><td>小批量是否合格</td><td>'+rowObj.data['smallIsQualifiedString']+'</td></tr>';
		}
		if(	middleReportURL != ""){
			htmlCode += '<tr><td>中批量验证报告</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['middleReportURL']+'>中批量测试报告</a></td></tr>'
    			+ '<tr><td>中批量是否合格</td><td>'+rowObj.data['middleIsQualifiedString']+'</td></tr>';
		}
    	htmlCode += '<tr><td>客户报备是否完成</td><td>'+rowObj.data['isFinishedAlertCustomerString']+'</td></tr>'
    		+ '<tr><td>依据</td><td>'+rowObj.data['alertCustomerNumber']+'</td></tr>'
    		+ '<tr><td>供应商变更是否完成</td><td>'+rowObj.data['isFinishedSupChangeString']+'</td></tr>'
    		+ '<tr><td>依据</td><td>'+rowObj.data['finishedSupChangeNumber']+'</td></tr>'
    	 	+ '<tr><td>通报客户供应商附件</td><td><a href='+chg_base_url+'viewDocument?docUrl='+rowObj.data['attachmentForAlert']+'>附件</a></td></tr>'
    	 	+ '<tr><td>安全件列名是否完成</td><td>'+rowObj.data['isFinishedSecurityString']+'</td></tr>'
    		+ '<tr><td>其他</td><td>'+rowObj.data['other']+'</td></tr>'
    		+ '<tr><td>变更验证结论是否合格</td><td>'+rowObj.data['changeResultIsQualifyString']+'</td></tr>'
    		+ '<tr><td>变更前状态</td><td>'+rowObj.data['beforeChangeStatus']+'</td></tr>'
    		+ '<tr><td>变更后状态</td><td>'+rowObj.data['afterChangeStatus']+'</td></tr>'
    		+ '<tr><td>是否同意变更</td><td>'+rowObj.data['isApproveChangeString']+'</td></tr>'
    		+ '<tr><td>拒绝理由</td><td>'+rowObj.data['rejectReason']+'</td></tr>'
    		+ '<tr><td>参评人员</td><td>'+rowObj.data['verifyMembers']+'</td></tr>'
    		+ '<tr><td>变更实施时间</td><td>'+rowObj.data['deployChangeDate']+'</td></tr>'
    		+ '<tr><td>组织部门</td><td>'+rowObj.data['evaDeptName']+'</td></tr>'
    		+ '<tr><td>组织人员</td><td>'+rowObj.data['evaLeaderName']+'</td></tr>'
    		+ '<tr><td>组织部门领导</td><td>'+rowObj.data['evaDeptMgrName']+'</td></tr>';
    		    		
    	htmlCode += '</tbody></table>' + EPRNSTR;
    	var btns = [{
			text:'打印申请单',handler:function() {
				printPage(htmlCode);
			}
		},{
			text:'关闭',handler:function() {
				win.close();
			}
		}];
		
    	var win = new Ext.Window({
			height:500 , width:600 , layout:'border',title:'变更通知',buttonAlign:'center',items:[{
				border:false,closable:true,scripts:true,autoScroll:true,region:'center',
	            discardUrl:true,nocache:true,timeout:9000,scope:this,html:htmlCode
			}],buttons:btns
		});
		win.show();
    }
};
Ext.extend(CMS.ExternalChangeManagePanel, Ext.grid.GridPanel);